<script>
import classNames from 'classnames'
import {ConfigConsumerProps} from '../config-provider'

export default {
  name: 'Page',
  functional: true,
  inject: {
    configProvider: {default: () => ConfigConsumerProps}
  },
  props: {
    scroll: {
      type: Boolean,
      default: true
    }
  },
  render (h, ctx) {
    const getPrefixCls = ctx.injections.configProvider.getPrefixCls
    const prefixCls = getPrefixCls('page')
    const pagerClass = classNames(`${prefixCls}`, {
      scrollable: ctx.props.scroll
    })
    const {data: {staticStyle = {}}} = ctx

    const component = <div class={pagerClass} style={staticStyle}>{ctx.children}</div>
    const page = ctx.props.scroll ? (
      <scroll-view>{component}</scroll-view>
    ) : (
      component
    )
    return page
  }
}
</script>
